package org.bluedream.core.utils;

import com.alibaba.fastjson.JSON;
import org.bluedream.comm.utils.EncryptUtil;

import java.util.HashMap;
import java.util.Map;

public class EncryptStringUtil {
    private EncryptStringUtil(){
        throw new AssertionError();
    }

    private static final String ADMIN_PATH = YmlRead.getContextPath();

    public static String base64Encode(Map<String , String> arg0){
        String str = JSON.toJSONString(arg0);
        return EncryptUtil.encodeBase64String(str);
    }

    public static String base64Decode(String arg0) throws Exception {
        return EncryptUtil.decodeBase64String(arg0);
    }

    public static void main(String[] args) throws Exception {
        Map<String , String> obj = new HashMap<>();
        obj.put("id" , "organizationForm");
        obj.put("menuName" , "组织表单");
        obj.put("jumpAddress" , ADMIN_PATH + "/organization/form");
        System.out.println(base64Encode(obj));
        String str = base64Encode(obj);
        str = "eyJtZW51TmFtZSI6IueUqOaIt+ihqOWNlSIsImlkIjoidXNlckZvcm0iLCJqdW1wQWRkcmVzcyI6Ii9hL3VzZXIvZm9ybSJ9";
        System.out.println(base64Decode(str));
    }
}
